<script setup lang="ts">
import { ref, getCurrentInstance, onMounted } from "vue";
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import { useUser, useConfig } from "@/store";
import { storeToRefs } from "pinia";

const userStore = useUser();

const {
  proxy: { $utils },
} = getCurrentInstance() as any;

let systemInfo = uni.getSystemInfoSync();

onLaunch(() => {
  let sysCustom: any = {};
  // 初始化自定义custom配置项
  sysCustom.statusH = systemInfo.statusBarHeight || 0;
  let capsule = uni.getMenuButtonBoundingClientRect();
  if (capsule) {
    sysCustom.B = capsule;
    sysCustom.H = sysCustom.statusH + 44;
    sysCustom.capsuleH = capsule.height;
  } else {
    sysCustom.H = sysCustom.statusH + 50;
  }
  useConfig().setCustom(sysCustom);

  $utils.getDiyData();
  if ($utils.checkLogin()) {
    userStore.initUser();
  }
});
onShow(() => {
  console.log("App Show");
});
onHide(() => {
  console.log("App Hide");
});
</script>
<style></style>
